﻿using System;

namespace PMS.Services.Utils.Captcha
{
    /// <summary>
    /// 生成的图片验证码格式
    /// </summary>
    public enum CaptchaImageFormat
    {
        /// <summary>
        /// Bmp图片
        /// </summary>
        Bmp = 1,
        /// <summary>
        /// Base64 String
        /// </summary>
        Base64 = 2,
        /// <summary>
        /// Jpeg/Jpg图片
        /// </summary>
        Jpeg = 3,
        /// <summary>
        /// Png图片
        /// </summary>
        Png = 4
    }

    /// <summary>
    /// 图形验证码校验结果
    /// </summary>
    public enum CaptchaVerifyCode
    {
        /// <summary>
        /// 输入验证码不能为空
        /// </summary>
        NullCaptcha = 1,
        /// <summary>
        /// 验证码校验超时
        /// </summary>
        Expired = 2,
        /// <summary>
        /// 验证码输入错误
        /// </summary>
        NotMatch = 3,
        /// <summary>
        /// 校验数据不完善、加密Captcha不是系统加密部分
        /// </summary>
        ErrorData = 4,
        /// <summary>
        /// 验证码校验成功
        /// </summary>
        Success = 5,
        /// <summary>
        /// Unknown Exception
        /// </summary>
        Exception = 6,
    }

    public class CaptchaVerifyResult
    {
        public CaptchaVerifyCode VerifyCode { get; set; }
        public string Message { get; set; }
    }
    /// <summary>
    /// Request Model from Frontend to Verify the Captcha
    /// </summary>
    public class CaptchaRequest
    {
        /// <summary>
        /// User Inputed Answer for Captcha Verify
        /// </summary>
        public string InputAnswer { get; set; }
        /// <summary>
        /// Encrypted Captcha Generated By CaptchaFactory for Result Comparing
        /// </summary>
        public string Captcha { get; set; }
    }

    /// <summary>
    /// Captcha Model
    /// https://github.com/PuzzledAlien/Captcha
    /// </summary>
    public partial class CaptchaInfo
    {
        /// <summary>
        /// 图片字节
        /// </summary>
        public byte[] Image { get; set; }

        public string CaptchBase64Data { get; set; }
        /// <summary>
        /// 图片中显示的字符（经过DES加密）
        /// </summary>
        public string Answer { get; set; }
        /// <summary>
        /// 设计后续有类似问题类的图片验证码
        /// </summary>
        public string Tip { get; set; }
        /// <summary>
        /// 验证码图片文件为类型
        /// </summary>
        public CaptchaImageFormat ContentType { get; set; }

    }
}
